<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class Controller extends CController
{
	/**
	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
	 */
	public $menu=array();
	/**
	 * @var array the breadcrumbs of the current page. The value of this property will
	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
	 * for more details on how to specify this property.
	 */
	public $breadcrumbs=array();
	
	private $_pageTitle;
	
	private $_pageKeywords = array();
	
	public function getQuery($name)
	{
		return isset($_GET[$name]) ? $_GET[$name] : null;
	}
	
	public function getPost($name)
	{
		return isset($_POST[$name]) ? $_POST[$name] : null;
	}
	
	public function display($params = array())
	{
		$this->render($this->getAction()->getId(), $params);
	}
	
	public function setPageTitle($title)
	{
	    $this->_pageTitle = CHtml::encode($title);
	}
	
	public function getPageTitle()
	{
	    if (null === $this->_pageTitle)
	        return Yii::app()->name;
	    else
	        return Yii::app()->name . ' - ' . $this->_pageTitle;
	}
	
	public function getPageKeywords()
	{
        $this->_pageKeywords[] = Yii::app()->name;
	    return implode(',', $this->_pageKeywords);
	}
	
	public function setPageKeywords($keyword)
	{
	    $this->_pageKeywords[] = $keyword;
	    return $this;
	}
}